package com.example.web;

import com.example.dao.UserRepository;
import com.example.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
//这是git的测试代码
@RestController
public class UserController {
    @Autowired
    private UserRepository userRepository;
    //consumes="application/json"方法仅处理request Content-Type为“application/json”类型的请求。
    // produces="application/json"方法仅处理request请求中Accept头中包含了"application/json"的请求，同时暗示了返回的内容类型为application/json;
    @RequestMapping(value="/user/{name}",method = {RequestMethod.GET,RequestMethod.POST})
    public User findByName1(@PathVariable String name)
    {
        System.out.println("查询我这里也进行了修改");
        return  userRepository.findByName(name);
    }
    @RequestMapping(value="/user/{name}",method = {RequestMethod.GET,RequestMethod.POST})
    public User findByName34(@PathVariable String name)
    {
        System.out.println("查询更改");
        return  userRepository.findByName(name);
    }
    @RequestMapping(value="/user/{name}/{age}",method = {RequestMethod.GET,RequestMethod.POST})
    public User findByNameAndAge(@PathVariable String name,@PathVariable int age)
    {
        System.out.println("查询");
        return  userRepository.findByNameAndAge(name,age);
    }
    @RequestMapping(value="/user1/{names}",method = {RequestMethod.GET,RequestMethod.POST})
    public User findByName2(@PathVariable("names") String name)
    {
        System.out.println("查询");
        return  userRepository.findByName(name);
    }
    @RequestMapping(value="/user",method = {RequestMethod.GET,RequestMethod.POST})
    public User findUser(@RequestParam("uname") String name, @RequestParam("uage")int age)
    {
        System.out.println("Post查询");
        return  userRepository.findByNameAndAge(name,age);
    }
    //这是git的测试代码
}
